package com.base.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * \* @author: hasee
 * \* Date: 2024/6/9
 * \* Time: 22:44
 * \* Description:
 * \
 */
@ControllerAdvice
public class MyExceptionAdvice {
    @ExceptionHandler(NullPointerException.class)
    public ModelAndView processException(NullPointerException ex){
        ModelAndView mv = new ModelAndView("error");
        mv.addObject("msg",ex.toString());
        return mv;
    }

    @ExceptionHandler(ArithmeticException.class)
    public ModelAndView processException2(ArithmeticException ex){
        ModelAndView mv = new ModelAndView("error");
        mv.addObject("msg",ex.toString());
        return mv;
    }
}